import os
import util

from google.appengine.ext import webapp
from google.appengine.ext.webapp import template

from Manager import Manager

class AchadoDetalhes( webapp.RequestHandler ):
	
	@util.loginRequired
	def get( self ):
		manager = Manager()
		
		key = self.request.get( 'key' )
		achado = manager.getAchado( key )
		conta_author = manager.getConta(achado.author)

		template_values = {
			'achado': achado,
			'conta_author': conta_author
		}

		path = os.path.join( os.path.dirname(__file__), 'templates/achadodetalhes.html' )
		self.response.out.write( template.render( path, template_values ) )
	
	@util.loginRequired	
	def post( self ):
		key = self.request.get( 'key' )
		manager = Manager()
		manager.achei( key )
		return self.get()

